package com.lanou.one;

import java.util.Objects;

/**
 * 
 * @author Lenovo
 *
 */
class People {
	protected double height;
	protected double weight;
	
	

	@Override
	public int hashCode() {
		return Objects.hash(height, weight);
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		People other = (People) obj;
		return Double.doubleToLongBits(height) == Double.doubleToLongBits(other.height)
				&& Double.doubleToLongBits(weight) == Double.doubleToLongBits(other.weight);
	}

	public void speakHello() {
		System.out.println("hello,height " + height 
				+ " weight " + weight);
	}

	public void averageHeight() {
		height = 170;
	}

	public void averageWeight() {
		weight = 140;
	}

}

class ChinaPeople extends People {
	public void chinaGongfu() {
		System.out.println("坐入钟，站入松，睡入弓");
	}
}

class AmericanPeople extends People {
	public void americanBoxing() {
		System.out.println("直拳，勾拳");
	}
}

public class PeopleTest {
	public static void main(String[] args) {
		People people = new ChinaPeople();
		people.height = 180;
		people.weight = 170;
		people.speakHello();
		people.averageHeight();
		people.averageWeight();
		people.speakHello();
		// 向下转型
		((ChinaPeople) people).chinaGongfu();
	}
}
